﻿#pragma once

#include <QDialog>
#include "ui_SetMEMSDataDialog.h"
#include <qfile.h>
#include <qfiledialog.h>
#include <qexception.h>
#include <qvector.h>

class MEMSDataHandler;
class MEMSDataCodec;
class MEMSDataSaver;
class SerialPortManager;

class SetMEMSDataDialog : public QDialog
{
  Q_OBJECT
private:
  Ui::SetMEMSDataDialog ui;
  QVector<QLabel*> label_filePathOfSavings;
  QVector<QLineEdit*> lineEdit_filePathOfSavings;
  QVector<QPushButton*> pushButton_filePathOfSavings;

  MEMSDataHandler* mEMSDataHandler = Q_NULLPTR;
  MEMSDataCodec* mEMSDataCodec = Q_NULLPTR;
  MEMSDataSaver* mEMSDataSaver = Q_NULLPTR;
  SerialPortManager* serialPortManager = Q_NULLPTR;

public:
  SetMEMSDataDialog(QWidget *parent = Q_NULLPTR);
  ~SetMEMSDataDialog();
public slots:
  int exec();
  void accept();
private slots:
  void slot_openFilePathDialog_1();
  void slot_openFilePathDialog_2();
  void slot_openFilePathDialog_3();
  void slot_openFilePathDialog_4();
  void slot_openFilePathDialog_5();
  void slot_openFilePathDialog_6();
  void slot_updateFilePathLineEdit();
  //模块化
private:
  void updateDataCollectionProtocol();
  void updateDataFilePath();
  void updateDataGroupCount();
  void addWidgetToList();
  void openFilePathDialog(int dataGroupIndex);
  void showFilePathMode(int modeIndex);
  void hideFilePathMode(int modeIndex);
  //geter and seter
public:
  MEMSDataHandler* getMEMSDataHandler();
  void setMEMSDataHandler(MEMSDataHandler* mEMSDataHandler);
  MEMSDataCodec* getMEMSDataCodec();
  void setMEMSDataCodec(MEMSDataCodec* mEMSDataCodec);
  MEMSDataSaver* getMEMSDataSaver();
  void setMEMSDataSaver(MEMSDataSaver* mEMSDataSaver);
  SerialPortManager* getSerialPortManager();
  void setSerialPortManager(SerialPortManager* serialPortManager);
};
